import com.itheima.config.SpringConfig;
import com.itheima.domain.NewTrip;
import com.itheima.domain.Trip;
import com.itheima.service.NewTripService;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;

import java.util.List;

//SpringJUnit4ClassRunner替代junit原生执行器
@RunWith(SpringJUnit4ClassRunner.class)
//加载注解配置类的
@ContextConfiguration(classes= {SpringConfig.class})
public class MyTest2 {
    @Autowired
    private NewTripService newTripService;

    @Test
    public void test(){
        newTripService.insert();
    }

    @Test
    public void test1(){
        List<Trip> list = newTripService.queryAll();
        for (Trip newTrip : list) {
            System.out.println("newTrip = " + newTrip);
        }

    }
}
